var pathName = document.location.pathname;
	var index = pathName.substr(1).indexOf("/");
	var result = pathName.substr(0,index+1);
	$(function(){
		getProductAll();
	})
	function getProductAll(){
			$.ajax({
				url:result+"/pro/all",
				dataType:"json",
				Type:"get",
				success:function(data){
					if(data.success){
						gender(data.data);
					}else{
						alert(data.message);
					}
				},
				error:function(){
					alert("请求响应出错");
				}
			})
		}
		function gender(data){
			$(".list").html("");
			for(var i=0;i<data.length;i++){
				var str = "<tr><td class='first w4 c'>"+(i+1)+"</td><td class='thumb'><img src='../../statics/images/product/"+data[i].epFileName+"' />"+
				"<a href='product-view.html?epId="+data[i].epId+"' target='_blank'>"+data[i].epName+"</a></td>"+
				"<td class='w1 c'><a href='product-modify.html?epId="+data[i].epId+"'>修改</a> <a href='javascript:Delete("+data[i].epId+");'>删除</a></td></tr>";
				$(".list").append(str);
			}
		}

		function Delete(data) {
			var pathName = document.location.pathname;
			var index = pathName.substr(1).indexOf("/");
			var result = pathName.substr(0, index + 1);
			if (confirm("确定要删除吗？")) {
				$.ajax({
					url : result + "/pro/delete",
					dataType : "json",
					data : "epId=" + data,
					Type : "get",
					success : function(data) {
						if (data.success) {
							alert(data.message);
							getProductAll();
						} else {
							alert(data.message);
						}
					},
					error : function() {
						alert("请求响应出错");
					}
				})
			}
		}